/*
 * db_sqlite.hpp
 *
 *  Created on: 2022年11月7日
 *      Author: dylan
 */

#ifndef _DM_OS_DB_DB_SQLITE_HPP_
#define _DM_OS_DB_DB_SQLITE_HPP_

#include <db.hpp>
#include <resultset_sqlite.hpp>
#include <unistd.h>

namespace iotplat {
    class CDbSqlite : public CDb {
    public:
        CDbSqlite(const char *dbName, const char *host = "localhost", short port = -1);

        ~CDbSqlite();

        EDbType dbType();

        bool isConnected();

        bool connect(const char *user, const char *pw);

        void disconnect();

        bool exec(const char *sql);

        int64_t execWithLastId(const char *sql);

        CResultSet *query(const char *sql);

        CResultSet *getTables(const char *pattern);

    private:
        sqlite3 *m_db;
    };
}
#endif /* DM_RUNTIME_INCLUDE_DM_OS_DB_DB_SQLITE_HPP_ */
